#include <iostream>
#include <queue>

using namespace std;

queue<int>q;
int n, m;

int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        q.push(i);
    }
    int cur = 1;
    while(!q.empty()){
        if(cur == m){
            cout << q.front() << " ";
            q.pop();
            cur = 1;
        }
        else{
            cur++;
            q.push(q.front());
            q.pop();
        }
    }
    return 0;
}